class SRVetDemolitions extends SRVeterancy
	abstract;

static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
{
	switch( CurLevel )
	{
	case 0:
		FinalInt = 0;
		break;
	case 1:
		FinalInt = 500000; // 0.5M
		break;
	case 2:
		FinalInt = 1500000; // 1M
		break;
	case 3:
		FinalInt = 3500000; // 2M
		break;
	case 4:
		FinalInt = 6000000; // 2.5M
		break;
	case 5:
		FinalInt = 10000000; // 4m
		break;
	case 6:
		FinalInt = 18000000; // 8m
		break;
	case 7:
		FinalInt = 30000000; // 12m
		break;
	case 8:
		FinalInt = 45000000; // 15m
		break;
	default:
		FinalInt = 70000000 * ( CurLevel - 8 );
	}
	return Min(StatOther.RExplosivesDamageStat,FinalInt);
}

static function float AddExtraAmmoFor(KFPlayerReplicationInfo KFPRI, Class<Ammunition> AmmoType)
{
	if ( AmmoType == class'FragAmmo' || AmmoType == class'Frag1Ammo' )
	{
		if( KFPRI.ClientVeteranSkillLevel < 6 )
			return ( 1.6 + 0.2 * float(KFPRI.ClientVeteranSkillLevel) ) * GetProperAmmoAmount(AmmoType);
		if( KFPRI.ClientVeteranSkillLevel == 6 )
			return 3.0 * GetProperAmmoAmount(AmmoType); // 10 grenades
		if( KFPRI.ClientVeteranSkillLevel == 7 )
			return 3.4 * GetProperAmmoAmount(AmmoType); // 12 grenades
		if( KFPRI.ClientVeteranSkillLevel == 8 )
			return 4.0 * GetProperAmmoAmount(AmmoType); // 15 grenades
		if( KFPRI.ClientVeteranSkillLevel > 8 )
			return 5.0 * GetProperAmmoAmount(AmmoType); // 20 grenades
	}
	else if ( AmmoType == class'PipeBombAmmo' )	
	{
		if( KFPRI.ClientVeteranSkillLevel < 6 )
			return ( 2.5 + 0.5 * float(KFPRI.ClientVeteranSkillLevel) ) * GetProperAmmoAmount(AmmoType);
		if( KFPRI.ClientVeteranSkillLevel == 6 )
			return 6.0 * GetProperAmmoAmount(AmmoType); // 12 mines
		if( KFPRI.ClientVeteranSkillLevel == 7 )
			return 7.0 * GetProperAmmoAmount(AmmoType); // 14 mines
		if( KFPRI.ClientVeteranSkillLevel == 8 )
			return 8.0 * GetProperAmmoAmount(AmmoType); // 16 mines
		if( KFPRI.ClientVeteranSkillLevel > 8 )
			return 10.0 * GetProperAmmoAmount(AmmoType); // 20 mines
	}
	else if ( AmmoType == class'LAWAmmoNew' || AmmoType == class'M79UAmmo' )
	{
		if ( KFPRI.ClientVeteranSkillLevel <= 9 )
		{
			return 1.05 + 0.05 * float(KFPRI.ClientVeteranSkillLevel);
		}
		else
		{
			return 1.50;
		}
	}
	return GetProperAmmoAmount(AmmoType);
}

static function int AddDamage(KFPlayerReplicationInfo KFPRI, KFMonster Injured, KFPawn DamageTaker, int InDamage, class<DamageType> DmgType)
{
	local float ret;

	if ( class<KFWeaponDamageType>(DmgType).default.bIsExplosive || class<DamTypeFrag>(DmgType) != none || class<DamTypePipeBomb>(DmgType) != none ||
		 class<DamTypeM79Grenade>(DmgType) != none || class<DamTypeM32Grenade>(DmgType) != none || class<DamTypeM203Nade>(DmgType) != none ||
		 class<DamTypeRocketImpact>(DmgType) != none || class<DamTypeWColt>(DmgType) != none || class<DamTypeRPG>(DmgType) != none )
	{
		if ( KFPRI.ClientVeteranSkillLevel == 0 )
			ret = 0.25;
		else if ( KFPRI.ClientVeteranSkillLevel == 1 )
			ret = 0.30;
		else if ( KFPRI.ClientVeteranSkillLevel == 2 )
			ret = 0.40;
		else if ( KFPRI.ClientVeteranSkillLevel == 3 )
			ret = 0.50;
		else if ( KFPRI.ClientVeteranSkillLevel == 4 )
			ret = 0.60;
		else if ( KFPRI.ClientVeteranSkillLevel == 5 )
			ret = 0.70;
		else if ( KFPRI.ClientVeteranSkillLevel == 6 )
			ret = 0.80;
		else if ( KFPRI.ClientVeteranSkillLevel == 7 )
			ret = 0.95;
		else if ( KFPRI.ClientVeteranSkillLevel == 8 )
			ret = 1.10;
		else if ( KFPRI.ClientVeteranSkillLevel > 8 )
			ret = 1.25;

		if ( Injured.Mass >= 510.00 && class<DamTypeWColt>(DmgType) == none )
		{
			if ( KFPRI.ClientVeteranSkillLevel <= 6 )
			{
				ret += 0.10 * float(KFPRI.ClientVeteranSkillLevel);
			}
			else if ( KFPRI.ClientVeteranSkillLevel <= 9 )
			{
				ret += 0.60 + 0.05 * float(KFPRI.ClientVeteranSkillLevel-6);
			}
			else
			{
				ret += 0.75;
			}
		}
	}
	
	ret += 1.00;
	
	if ( class<DamTypePipeBomb>(DmgType) != none )
	{
		ret *= 1.50;
	}
	if ( class<DamTypeFrag>(DmgType) != none )
	{
		ret *= 2.00;
	}

	return ret * Super.AddDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function int ReduceDamage(KFPlayerReplicationInfo KFPRI, KFPawn Injured, KFMonster DamageTaker, int InDamage, class<DamageType> DmgType)
{
	if ( class<KFWeaponDamageType>(DmgType).default.bIsExplosive || class<DamTypeFrag>(DmgType) != none || class<DamTypePipeBomb>(DmgType) != none ||
		 class<DamTypeM79Grenade>(DmgType) != none || class<DamTypeM32Grenade>(DmgType) != none ||
		 class<DamTypeRocketImpact>(DmgType) != none || class<DamTypeRPG>(DmgType) != none || class<DamTypeM203Nade>(DmgType) != none )
	{
		if ( KFPRI.ClientVeteranSkillLevel == 0 )
			return float(InDamage) * 0.60;
		else if ( KFPRI.ClientVeteranSkillLevel == 1 )
			return float(InDamage) * 0.55;
		else if ( KFPRI.ClientVeteranSkillLevel == 2 )
			return float(InDamage) * 0.50;
		else if ( KFPRI.ClientVeteranSkillLevel == 3 )
			return float(InDamage) * 0.45;
		else if ( KFPRI.ClientVeteranSkillLevel == 4 )
			return float(InDamage) * 0.40;
		else if ( KFPRI.ClientVeteranSkillLevel == 5 )
			return float(InDamage) * 0.35;
		else if ( KFPRI.ClientVeteranSkillLevel == 6 )
			return float(InDamage) * 0.30;
		else if ( KFPRI.ClientVeteranSkillLevel == 7 )
			return float(InDamage) * 0.20;
		else if ( KFPRI.ClientVeteranSkillLevel == 8 )
			return float(InDamage) * 0.10;
		else if ( KFPRI.ClientVeteranSkillLevel > 8 )
			return 0;
	}
	return Super.ReduceDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function class<Grenade> GetNadeType(KFPlayerReplicationInfo KFPRI)
{
	return class'StickyNade';
}

// Change the cost of particular items
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
	if ( Item == class'PipeBombPickup' )
		// Todo, this won't need to be so extreme when we set up the system to only allow him to buy it perhaps
		return FMax(0.10 - (0.01 * float(KFPRI.ClientVeteranSkillLevel)),0.02f) * GetProperCostScaling(Item); // Up to 98% discount on PipeBomb
	else if ( Item == class'M79Pickup' || Item == class 'M32Pickup' || Item == class 'LawPickup' || Item == class 'WColtPickup'
			|| Item == class 'RPGPickup' || Item == class 'LAWSGMPickup' || Item == class 'Bal_M4203_DemPickup'
			|| Item == class 'M32NewPickup' || Item == class'M79UPickup' || Item == class'EX41Pickup' )

		return GetDefaultCostScaling(KFPRI.ClientVeteranSkillLevel) * GetProperCostScaling(Item);
	return GetProperCostScaling(Item);
}

// Change the cost of particular ammo
static function float GetAmmoCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
	if ( Item == class'PipeBombPickup' )
		// Todo, this won't need to be so extreme when we set up the system to only allow him to buy it perhaps
		return FMax(0.10 - (0.01 * float(KFPRI.ClientVeteranSkillLevel)),0.02) * GetProperAmmoCostScaling(Item); // Up to 96% discount on PipeBomb
	return GetProperAmmoCostScaling(Item);
}

// Give Extra Items as default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
	local Inventory I;
	
	super.AddDefaultInventory(KFPRI,P);
	
	if ( SRPlayerReplicationInfo(KFPRI).bRespawned )
		return;

	if ( KFPRI.ClientVeteranSkillLevel > 2 )
	{
		KFHumanPawn(P).CreateInventoryVeterancy("KFMod.PipeBombExplosive", GetCostScaling(KFPRI, class'PipeBombPickup'));
		GiveAmmo(KFHumanPawn(P),Max((KFPRI.ClientVeteranSkillLevel-3)/3,0),class'PipeBombExplosive');
	}

	if ( KFPRI.ClientVeteranSkillLevel > 2 && KFPRI.ClientVeteranSkillLevel < 6 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.M79U", GetCostScaling(KFPRI, class'M79UPickup'));

	if ( KFPRI.ClientVeteranSkillLevel > 5 && KFPRI.ClientVeteranSkillLevel < 9 )
	{
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.EX41GrenadeLauncher", GetCostScaling(KFPRI, class'EX41Pickup'));
	}
	
	if ( KFPRI.ClientVeteranSkillLevel > 5 )
	{
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.SelfDestruct", 0);
	}

	if ( KFPRI.ClientVeteranSkillLevel > 8 )
	{
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.WColt", GetCostScaling(KFPRI, class'WColtPickup'));
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.M32GrenadeLauncherNew", GetCostScaling(KFPRI, class'M32NewPickup'));
	}

	SRPlayerReplicationInfo(KFPRI).bRespawned = true;
}

static function int AddCarryMaxWeight(KFPlayerReplicationInfo KFPRI)
{
	local int ret;
	
	if ( KFPRI.ClientVeteranSkillLevel > 9 )
		ret = 2;
	else
		ret = 0;
		
	return ret + Super.AddCarryMaxWeight(KFPRI);
}

static function float GetReloadSpeedModifier(KFPlayerReplicationInfo KFPRI, KFWeapon Other)
{
	if ( WColt(Other) != none && KFPRI.ClientVeteranSkillLevel > 9 )
	{
		return 1.35 * Super.GetReloadSpeedModifier(KFPRI,Other);
	}
	return Super.GetReloadSpeedModifier(KFPRI,Other);
}

static function bool IsPerkTarget(PlayerReplicationInfo PRI, class<Actor> TargetClass)
{
	if ( TargetClass == class'DKFleshpound' || TargetClass == class'DKCurrent' )
	{
		return true;
	}

	return Super.IsPerkTarget(PRI,TargetClass);
}

defaultproperties
{
     CustomLevelInfo="%s extra Explosives damage|%r resistance to Explosives|120% increase in grenade capacity|Can carry %x Remote Explosives|%y discount on Explosives|%d off Remote Explosives|Spawn with an M79 and Pipe Bomb"
     PerkIndex=6
	 BronzeIcon=Texture'SunriseHUD.Icons.Perk_Demolition_Bronze'
	 SilverIcon=Texture'SunriseHUD.Icons.Perk_Demolition_Silver'
	 GoldIcon=Texture'SunriseHUD.Icons.Perk_Demolition_Gold'
     OnHUDIcon=Texture'KillingFloor2HUD.Perk_Icons.Perk_Demolition'
     OnHUDGoldIcon=Texture'KillingFloor2HUD.Perk_Icons.Perk_Demolition_Gold'
     VeterancyName="Demolitions"
     Requirements(0)="Deal %x damage with the Explosives"
     SRLevelEffects(0)="25% extra Explosives and Colt Python damage|Grenades stick to enemies|40% resistance to Explosives|Can carry 8 grenades|Can carry 5 Pipe Bombs|5% extra M79 and LAW ammo|50% discount on Explosives and Colt Python|90% discount on Pipe Bombs"
     SRLevelEffects(1)="30% extra Explosives and Colt Python damage|40% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|45% resistance to Explosives|Can carry 9 grenades|Can carry 6 Pipe Bombs|10% extra M79 and LAW ammo|55% discount on Explosives and Colt Python|91% discount on Pipe Bombs"
     SRLevelEffects(2)="40% extra Explosives and Colt Python damage|60% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|50% resistance to Explosives|Can carry 10 grenades|Can carry 7 Pipe Bombs|15% extra M79 and LAW ammo|60% discount on Explosives and Colt Python|92% discount on Pipe Bombs"
     SRLevelEffects(3)="50% extra Explosives and Colt Python damage|80% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|55% resistance to Explosives|Can carry 11 grenades|Can carry 8 Pipe Bombs|20% extra M79 and LAW ammo|65% discount on Explosives and Colt Python|93% discount on Pipe Bombs|Spawn with an M79 and 2 Pipe Bombs"
     SRLevelEffects(4)="60% extra Explosives and Colt Python damage|100% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|60% resistance to Explosives|Can carry 12 grenades|Can carry 9 Pipe Bombs|25% extra M79 and LAW ammo|70% discount on Explosives and Colt Python|94% discount on Pipe Bombs|Spawn with an M79 and 2 Pipe Bombs"
     SRLevelEffects(5)="70% extra Explosives and Colt Python damage|120% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|65% resistance to Explosives|Can carry 13 grenades|Can carry 10 Pipe Bombs|30% extra M79 and LAW ammo|70% discount on Explosives and Colt Python|95% discount on Pipe Bombs|Spawn with an M79 and 2 Pipe Bombs"
     SRLevelEffects(6)="80% extra Explosives and Colt Python damage|140% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|70% resistance to Explosives|Can carry 15 grenades|Can carry 12 Pipe Bombs|35% extra M79 and LAW ammo|70% discount on Explosives and Colt Python|96% discount on Pipe Bombs|Spawn with an EX41, Self-Destruct and 3 Pipe Bombs"
	 SRLevelEffects(7)="95% extra Explosives and Colt Python damage|160% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|80% resistance to Explosives|Can carry 17 grenades|Can carry 14 Pipe Bombs|40% extra M79 and LAW ammo|75% discount on Explosives and Colt Python|97% discount on Pipe Bombs|Spawn with an EX41, Self-Destruct and 3 Pipe Bombs"
	 SRLevelEffects(8)="110% extra Explosives and Colt Python damage|180% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|90% resistance to Explosives|Can carry 20 grenades|Can carry 16 Pipe Bombs|45% extra M79 and LAW ammo|75% discount on Explosives and Colt Python|98% discount on Pipe Bombs|Spawn with an EX41, Self-Destruct and 3 Pipe Bombs"
	 SRLevelEffects(9)="125% extra Explosives and Colt Python damage|200% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|100% resistance to Explosives|Can carry 25 grenades|Can carry 20 Pipe Bombs|50% extra M79 and LAW ammo|80% discount on Explosives and Colt Python|98% discount on Pipe Bombs|Spawn with an M32, Self-Destruct, Colt Python and 4 Pipe Bombs"
	 SRLevelEffects(10)="125% extra Explosives and Colt Python damage|200% extra explosive damage to heavy-mass monsters|Grenades stick to enemies|100% resistance to Explosives|Can carry 25 grenades|Can carry 20 Pipe Bombs|50% extra M79 and LAW ammo|80% discount on Explosives and Colt Python|98% discount on Pipe Bombs|Spawn with an M32, Self-Destruct, Colt Python, 4 Pipe Bombs and 100 armor|Elite abilities:|70% extra headshot damage with 9mm tactical|Can carry 17 weight blocks|Weapon Mastery - 35% faster Colt Python Reload"
}
